Introduce CallRelatedSymbolSink to avoid affect name resolution with related symbols#19361
Open
Introduce CallRelatedSymbolSink to avoid affect name resolution with related symbols#19361
Conversation
…bols Address auduchinok's review comments on PR #19252: related symbols (union case testers, copy-and-update record types) are now reported via a separate NotifyRelatedSymbolUse sink instead of abusing NotifyNameResolution. - Add [<Flags>] RelatedSymbolUseKind enum (None/UnionCaseTester/CopyAndUpdateRecord/All) - Add NotifyRelatedSymbolUse to ITypecheckResultsSink interface - Refactor RegisterUnionCaseTesterForProperty to use the new sink - Refactor copy-and-update in TcRecdExpr to use CallRelatedSymbolSink - Add ?relatedSymbolKinds parameter to GetUsesOfSymbolInFile (default: None) - Wire up VS FAR to pass relatedSymbolKinds=All - Write related symbols to ItemKeyStore for background FAR - Update semantic classification tests: tester properties now classified as Property (not UnionCase) since they're no longer in capturedNameResolutions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
abonie
reviewed
Feb 27, 2026
| let results = checker.ParseAndCheckFileInProject(fileName, snapshot) |> Async.RunSynchronously | ||
| let checkResults = getTypeCheckResult results | ||
| checkResults.GetSemanticClassification(None) | ||
| checkResults.GetSemanticClassification(None, RelatedSymbolUseKind.All) |
Member
There was a problem hiding this comment.
Does it make sense to add tests for other cases -- other values of RelatedSymbolUseKind?
abonie
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #19252 — refactors how "related" symbols (union case testers on properties, record types in copy-and-update expressions) are reported.
PR #19252 misused
NotifyNameResolutionwithreplace=trueto inject these symbols as if they were actual name resolutions. This corrupted data for all sink consumers (colorization, symbol info, code lenses) since the items were not genuine resolutions.This PR introduces:
NotifyRelatedSymbolUsesink method, keeping the main resolution path clean[<Flags>] RelatedSymbolUseKindenum (UnionCaseTester,CopyAndUpdateRecord,All) in the public FCS API?relatedSymbolKindsparameters onGetUsesOfSymbolInFileandGetSemanticClassification, letting consumers opt in to the specific related symbol kinds they needVS passes
All; consumers that do not pass it get no related symbols (backward compatible default).